import { ApiProperty } from '@nestjs/swagger';
import { Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Product } from '../../product/assets/product.entity';
import { Platform } from '../../platform/assets/platform.entity';
import { Coupon } from '../../coupon/assets/coupon.entity';

@Entity('couponproduct')
export class CouponProduct {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => Product)
  @ApiProperty({ description: '规格', type: () => Product })
  @JoinColumn()
  product: Product;

  @ManyToOne(() => Platform)
  @ApiProperty({ description: '平台', type: () => Platform })
  @JoinColumn()
  platform: Platform;

  @ManyToOne(() => Coupon, { cascade: ['remove'], onDelete: 'CASCADE' })
  @ApiProperty({ description: '优惠券', type: () => Coupon })
  @JoinColumn()
  coupon: Coupon;

  // @Column({ nullable: true })
  // @ApiProperty({ description: '规格名称' })
  // productName: string;

  // @Column()
  // @ApiProperty({ description: '平台名称' })
  // platformName: string;
}
